/**
 * 
 */
package org.cnbi.service.impl;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.cnbi.dao.IHandleDao;
import org.cnbi.service.IndustryParamsService;
import org.cnbi.utils.exception.BusinessException;
import org.cnbi.utils.pojo.industry.IndustryParamBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * Copyright © 2014中国经邦. All rights reserved.
 * @author 龚佳新
 * @date 2014年5月28日下午12:34:57
 * @cnbi-web
 */
@Service
public class IndustryParamsServiceImpl implements IndustryParamsService {
	
	protected static  final Log logger = LogFactory.getLog(IndustryParamsServiceImpl.class);
	
	@Autowired
	private IHandleDao hanldDao;

	/* 
	 * @data 2014年5月28日  复写的方法
	 * @see org.cnbi.service.IndustryParamsService#queryIndustryParamBean(java.lang.String, org.cnbi.utils.pojo.industry.IndustryParamBean)
	 */
	@Cacheable(value = "locationSearchCache", key = "#param.cacheKey")//cacheKey
	@Override
	public IndustryParamBean queryIndustryParamBean(String sql, IndustryParamBean param) {
		try {
			 List<IndustryParamBean> list = (List<IndustryParamBean>) hanldDao.query(sql,param);
			 if(null!= list && list.size() >0){
				 logger.info("成功缓存了key="+param.getCacheKey()+"行业参数数据 ");
				 return list.get(0);
			 }
			 else{
				 return param;
			 }
		} catch (Exception e) {
			throw new BusinessException("查询行业参数【"+param.getCode()+"】时出错了"+e);
		}
		
	}

}
